FROM {{ namespace }}/{{ image_prefix }}openstack-base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block letsencrypt_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{% if base_package_type == 'rpm' %}
    {% set letsencrypt_packages = [
        'openssh-clients',
        'cronie'
    ] %}
{% elif base_package_type == 'deb' %}
    {% set letsencrypt_packages = [
        'openssh-client',
        'cron'
    ] %}
{% endif %}
{{ macros.install_packages(letsencrypt_packages | customizable("packages")) }}

COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN chmod 644 /usr/local/bin/kolla_extend_start

{% block lego_repository %}
ENV lego_version=4.6.0
ENV lego_download_url=https://github.com/go-acme/lego/releases/download/v${lego_version}/lego_v${lego_version}_linux_{{debian_arch}}.tar.gz
{% endblock %}

{% block lego_install %}
RUN curl -o /tmp/lego.tar.gz ${lego_download_url} \
    && tar xvf /tmp/lego.tar.gz -C /opt/ \
    && rm -f /tmp/lego.tar.gz
{% endblock %}

{% block letsencrypt_footer %}{% endblock %}
{% block footer %}{% endblock %}
